/* 
 * File:   Neuron.h
 * Author: jcrada
 *
 * Created on October 23, 2008, 2:13 PM
 */

#ifndef _NEURON_H
#define	_NEURON_H
#include <QtXml/QDomElement>
#include <QtXml/QDomDocument>
namespace jcrada {

    class Neuron {
    public:

        enum eActivationFunction {
            AF_NONE = -1, AF_SIGMOID, AF_TANH, AF_COUNT,
        };
    private:
        int _number_of_inputs;
        double * _inputs;
        double * _weights;
        double _threshold;
        eActivationFunction _activation_function;

    public:
        Neuron( int inputs );
        virtual ~Neuron( );

        virtual double output( ) const;

        virtual Neuron* clone( ) const;

        static Neuron* fromXml( QDomElement& element, bool* ok );
        virtual void toXml( QDomDocument& xml, QDomElement* parent = NULL ) const;

        static int main( int argc, char** argv );

        virtual int getNumberOfInputs( ) const {
            return this->_number_of_inputs;
        }

        virtual void setInput( int index, double value ) {
            this->_inputs[index] = value;
        }

        virtual double getInput( int index ) const {
            return this->_inputs[index];
        }

        virtual void setWeight( int index, double value ) {
            this->_weights[index] = value;
        }

        virtual double getWeight( int index ) const {
            return this->_weights[index];
        }

        virtual void setThreshold( double value ) {
            this->_threshold = value;
        }

        virtual double getThreshold( ) const {
            return this->_threshold;
        }

        virtual void setActivationFunction( eActivationFunction function ) {
            this->_activation_function = function;
        }

        virtual eActivationFunction getActivationFunction( ) const {
            return this->_activation_function;
        }

    };
}


#endif	/* _NEURON_H */

